package fem2.pre_and_post;

import java.io.IOException;
import java.util.ArrayList;

import org.junit.Test;

import fem2.Debugger;
import fem2.Mesh;
import fem2.MeshGenerator;
import fem2.MeshUtilities;

public class HyplasMeshGeneratorTest {

	@Test
	public void test1() {
		String fn = "/home/hbui/workspace/hyplasf/Debug/data_files/08_4_3_d-p_innercone.dat";
		MeshGenerator mg = new HyplasMeshGenerator(fn);
		ArrayList<double[]> nodes = mg.getNodes(2);
		for (int i = 0; i < nodes.size(); i++) {
			Debugger.watch(i + ": ", nodes.get(i));
		}
		ArrayList<ArrayList<Integer>> conn = mg.getConnectivities();
		for (int i = 0; i < conn.size(); i++) {
			System.out.print(i + ": ");
			for (int j = 0; j < conn.get(i).size(); j++) {
				System.out.print(conn.get(i).get(j) + " ");
			}
			System.out.println();
		}

		try {
			Mesh mesh = mg.getMesh(2);
			MeshUtilities.writeGiDMesh(mesh,
					"/home/hbui/kratos_janosch/strip-footing.gid/hyplas-mesh.msh");
			MeshUtilities.writeGmshMesh(mesh,
					"/home/hbui/kratos_janosch/strip-footing.gid/hyplas-mesh.gmsh.msh");
		} catch (IOException e) {
			throw new Error("Write failed");
		}
	}
}
